//
//  BellContentView.m
//  WangLottery
//
//  Created by 黄修勇 on 12-4-25.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "BellContentView.h"

@implementation BellContentView

@synthesize numbersOfLine=_numbersOfLine;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

-(void)setNumbersOfLine:(NSInteger)numbersOfLine{

    if (numbersOfLine==_numbersOfLine) {
        return;
    }
    _numbersOfLine=numbersOfLine;
    [self layoutSubviews];
}
-(void)layoutSubviews{

    if (_numbersOfLine==0||self.subviews.count<2) {
        return;
    }
    UIView *view=[self.subviews objectAtIndex:0];
    float tempWeidh=view.frame.size.width;
    float tempHeight=view.frame.size.height;
    
    float bellMargin=(self.frame.size.width-30.0f-_numbersOfLine*tempWeidh)/(_numbersOfLine-1);
    
    for (int i=0; i<self.subviews.count; i++) {
        UIView *view=[self.subviews objectAtIndex:i];
        NSInteger line=i/7;
        view.frame=CGRectMake(BellLeftMargin+i%7*(tempWeidh+bellMargin),BellTopMargin+line*(view.frame.size.height+10.0f), tempWeidh, tempHeight);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
